﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace AutoC
{
    class Program
    {
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessageTimeout(
        IntPtr hWnd,
        uint Msg,
        UIntPtr wParam,
        string lParam,
        uint fuFlags,
        uint uTimeout,
        out UIntPtr lpdwResult
    );


        static void Main(string[] args)
        {
            IntPtr HWND_BROADCAST = (IntPtr)0xffff;
            uint WM_SETTINGCHANGE = (uint)0x001A;
            uint SMTO_ABORTIFHUNG = (uint)0x02;
            UIntPtr dwReturnValue = (UIntPtr)0;
            SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, (UIntPtr)0,
         "Environment", SMTO_ABORTIFHUNG,
         5000, out dwReturnValue);
        }
    }
}
